﻿using MediatR;
using RBAC.Domain;
using RBAC.Domain.Service.Interfae;
using RBACDuYaJun.Api.Appliction.Command.RoleCommand;

namespace RBACDuYaJun.Api.Appliction.CommandHandlers.RoleHanders
{
    public class RoleUpdateCommandHandler : IRequestHandler<RoleUpdateCommand, int>
    {
        private readonly IRoleService _roleService;
        public RoleUpdateCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }

        public async Task<int> Handle(RoleUpdateCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.UpdateRole(new Roles() { roleId = request.RoleId, 
                roleName = request.RoleNames,
                updateName="王宏",updateDate=DateTime.Now,
                addName=request.AddName,addDate=request.AddDate});
        }
    }
}
